package ui.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.just.agentweb.AgentWeb;

import base.activity.BaseActivity;
import student.andlei.com.student.R;

/**
 * author : ChenHuiMing
 * date : 2018/9/25
 * email : 907399255@qq.com
 * description : Web
 */
public class WebActivity extends BaseActivity {

    public static final String EXTRA_URL = "extra_url";

    private AgentWeb mAgentWeb;
    private LinearLayout mLinearLayout;

    private String mUrl;

    public static void startWebActivity(Context context, String url) {
        Intent intent = new Intent(context, WebActivity.class);
        intent.putExtra(EXTRA_URL, url);
        context.startActivity(intent);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.webview;
    }

    @Override
    protected void findViews() {
        mLinearLayout = getView(R.id.ll);
    }

    @Override
    protected void formatViews() {

    }

    @Override
    protected void formatData() {
        mAgentWeb = AgentWeb.with(this)
                .setAgentWebParent(mLinearLayout, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
                .useDefaultIndicator()
                .createAgentWeb()
                .ready()
                .go(mUrl);
    }

    @Override
    protected void getBundle(Bundle bundle) {
        mUrl = getIntent().getStringExtra(EXTRA_URL);
        setTitle("网页");
    }

    @Override
    public void onClick(View view) {

    }
}
